cmake_minimum_required(VERSION 3.16)

project(demo LANGUAGES C CXX)

set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
get_filename_component(BASE_DIR ${SOURCE_DIR} DIRECTORY)

include(${BASE_DIR}/cmake/common.cmake)

set(OUTPUT_DIR ${BASE_DIR}/output)
set(DEPEND_LIB ${OUTPUT_DIR}/lib)
set(DEPEND_INC ${OUTPUT_DIR}/include)

set(CRYPTO_FRAMEWORK_DIR ${BASE_DIR}/security/crypto_framework)
set(CERTIFICATE_FRAMEWORK_DIR ${BASE_DIR}/security/certificate_framework)

set(MAIN_INC
  ${DEPEND_INC}
  ${CRYPTO_FRAMEWORK_DIR}/common/inc
  ${CRYPTO_FRAMEWORK_DIR}/interfaces/inner_api/algorithm_parameter
  ${CRYPTO_FRAMEWORK_DIR}/interfaces/inner_api/common
  ${CRYPTO_FRAMEWORK_DIR}/interfaces/inner_api/crypto_operation
  ${CRYPTO_FRAMEWORK_DIR}/interfaces/inner_api/key
  ${CRYPTO_FRAMEWORK_DIR}/plugin/openssl_plugin/common/inc
  ${CRYPTO_FRAMEWORK_DIR}/plugin/openssl_plugin/crypto_operation/md/inc
  ${CRYPTO_FRAMEWORK_DIR}/frameworks/spi
)

set(MAIN_SRC
  ${CRYPTO_FRAMEWORK_DIR}/common/src/object_base.c
  ${CRYPTO_FRAMEWORK_DIR}/common/src/blob.c
  ${CRYPTO_FRAMEWORK_DIR}/common/src/memory.c
  ${CRYPTO_FRAMEWORK_DIR}/common/src/utils.c
  ${CRYPTO_FRAMEWORK_DIR}/plugin/openssl_plugin/common/src/openssl_common.c
  ${CRYPTO_FRAMEWORK_DIR}/plugin/openssl_plugin/common/src/openssl_adapter.c
  ${CRYPTO_FRAMEWORK_DIR}/plugin/openssl_plugin/crypto_operation/md/src/md_openssl.c
  ${CRYPTO_FRAMEWORK_DIR}/frameworks/crypto_operation/md.c
  ${SOURCE_DIR}/test/mock.cpp
  ${SOURCE_DIR}/test/main.cpp
)

add_executable(main_test ${MAIN_SRC})
target_include_directories(main_test PRIVATE ${MAIN_INC})
target_link_directories(main_test PRIVATE ${DEPEND_LIB})
target_link_libraries(main_test
  PRIVATE EXE_COMPILE_CONFIG
  PUBLIC EXE_LINK_CONFIG # crypto_common crypto_openssl_plugin crypto_framework
)
target_link_options(main_test PRIVATE
  -Wl,--wrap=HcfMalloc
  -Wl,--wrap=OpensslEvpMdCtxSize
  -Wl,--wrap=HcfIsClassMatch
  -Wl,--wrap=HcfIsStrValid
  -Wl,--wrap=OpensslEvpDigestInitEx
)
